<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Application;

class ApplicationController extends Controller
{
    public function create(Request $request){
        $request->validate([
            'fio' => 'required|max:255',
            'email' => 'required|max:255',
            'phone' => 'required|max:255',
            'text' => 'required|max:255',
        ]);

        $application = new Application();
        $application->fio = $request->input('fio');
        $application->email = $request->input('email');
        $application->phone = $request->input('phone');
        $application->text = $request->input('text');
        $application->save();
        return back()->with('success', 'Спасибо за сообщение! Мы свяжемся с вами в ближайшее время.');
    }
}
